import type { App } from "vue";
import type { Pinia } from "pinia";


import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css';
import zhCn from 'element-plus/es/locale/lang/zh-cn';

import qaTable from "./qa-table.vue";
import qaForm from "./qa-form.vue";
import qaDatePciker from "./qa-date-pciker.vue";

const components = [ {
    name: "qa-table",
    component: qaTable
},{
    name: "qa-form",
    component: qaForm
},{
    name: "qa-date-pciker",
    component: qaDatePciker
}]

type BuildOptions = {
    login: {
        url: string,
        pinin: Pinia
    }
}

const quickApp = {
    install(app: App, options: BuildOptions) {

        app.use(ElementPlus, {
            locale: zhCn,
        })

        components.forEach(({ name, component }) => {
            // 如果组件本身没有 name 属性，则可以使用提供的 `name`
            app.component(name, component);
        });
        
        // // 手动触发初始存储
        if (!localStorage.getItem('config')) {
            localStorage.setItem('config', JSON.stringify(options));
        }

    }
}

export default quickApp;